//用栈实现队列
#include <stack>
using namespace::std;
class MyQueue {
private:
    stack<int> pushQ,popQ;

    void switch_stack()
    {
        while(!pushQ.empty())
        {
            popQ.push(pushQ.top());
            pushQ.pop();
        }
    }
public:
    MyQueue() {

    }
    
    
    void push(int x) {
        pushQ.push(x);
    }
    
    int pop() {
        if (popQ.empty())
        {
            switch_stack();
        }
        int x = popQ.top();
        popQ.pop();
        
        return x;
    }
    
    int peek() {
        if (popQ.empty())
        {
            switch_stack();
        }
        return popQ.top();
    }
    
    bool empty() {
        return popQ.empty() && pushQ.empty();
    }
};
